home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
music
/
kardp11.zip
/
KARAFM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-23
|
4KB
|
160 lines
/*
KARAOKE
Copyright (c) 1993 94 JP COCATRIX . All rights reserved.
*/
/* This is the interface module used in karados
given as an explaination of how the resident code like Ultramid
is used.
These primitives are called only if the output mode is s (-po=s)
I Hope it is self documented.
If loading a patches is no meaning for you, just ignore in the TSR
The APP_START and APP_END is only a protection for multiple users
to avoid the remove of the TSR if a program is still using it.
The key for detection for an other TSR than ULTRAMID
is KARADOS. Dont use ULTRAMID
*/
#include <stdio.h>
#include <string.h>
#include <dos.h>
#define TSR_LOAD_PATCH 12
#define TSR_UNLOAD_ALL_PATCHES 15
#define TSR_MIDI_OUT 16
#define TSR_ALL_NOTES_OFF 18
#define TSR_APP_START 26
#define TSR_APP_END 27
#define control_change 0xb0
extern enum HARD {RIEN,SB,GUS} hardware;
extern void SaySo(char *texte,int multiple);
extern short inrange(unsigned char,unsigned char min,unsigned char max);
extern const char *getInstrument(unsigned char);
void sbFmSound(int );
//*******************************************************************
// code Synth. output
//*******************************************************************
void (far *um_hook)(void) = 0L;
void um_parameter( int channel, int control, int value )
{
sbFmSound( (control_change+channel) );
sbFmSound( control );
sbFmSound( value );
}
void loadpatch( int patch )
{
char strg[80];
if (um_hook)
{
if (patch <128)
sprintf(strg,"Loading %s",getInstrument(patch));
else
{
if (!inrange(patch,128+27,128+87)) return;
sprintf(strg,"Loading drum %d",patch-128);
}
SaySo(strg,6);
_AX = TSR_LOAD_PATCH;
_CX = patch;
(*um_hook)();
}
}
int reset_um( )
{
int i;
_AX = TSR_ALL_NOTES_OFF;
if (um_hook) (*um_hook)();
for (i=0; i < 16; i++) {
um_parameter(i, 0x78, 0); /* all sounds off */
um_parameter(i, 0x79, 0); /* reset all controllers */
um_parameter(i, 100, 0); /* RPN MSB 0 */
um_parameter(i, 101, 0); /* RPN LSB 0 */
um_parameter(i, 6, 2); /* Pitch Bend Sensitivity MSB */
um_parameter(i, 38, 0); /* Pitch Bend Sensitivity LSB */
}
return(1);
}
void um_cleanup( void )
{
reset_um();
if (um_hook)
{
SaySo("Unload Patches",6);
_AX = TSR_UNLOAD_ALL_PATCHES;
(*um_hook)();
_AX = TSR_APP_END;
(*um_hook)();
}
}
//***********************************************************************
// code commun common code
//***********************************************************************
// name with FM are for historical reasons !!
#pragma warn -par
int initfm()
{
int vector, i;
char far *stamp;
switch (hardware)
{
case GUS:
case SB:
for (vector=0x78; vector <= 0x7f; vector++)
{
um_hook = (void (far *)())getvect(vector);
stamp = (char far *)MK_FP( FP_SEG(um_hook), 0x103 );
if ((strncmp(stamp, "ULTRAMID", 8) == 0)||(strncmp(stamp, "KARADOS", 7) == 0)) break;
}
if (vector <= 0x7f) {
if (um_hook)
{
_AX = TSR_APP_START;
(*um_hook)();
_AX = TSR_UNLOAD_ALL_PATCHES;
(*um_hook)();
reset_um();
}
} else
{
um_hook = 0L;
return(1);
}
return(0);
case RIEN :
default:
printf (" No synth. Sorry.\n");
return (1);
}
}
#pragma warn .par
void sbFmSound(int car )
{
switch (hardware)
{
case GUS:
case SB:
if (um_hook)
{
_AX = TSR_MIDI_OUT;
_CX = car;
(*um_hook)();
}
break;
default:break;
}
}